import request from '@/utils/request'


// 通用上传
export function uploadFile(data) {
  return request({
    url: '/common/upload',
    method: 'post',
    data: data
  })
}

export function uploadPortalMenuFile(data) {
  return request({
    url: '/common/upload/portalMenu',
    method: 'post',
    data: data
  })
}

export function uploadBannerFile(data) {
  return request({
    url: '/common/upload/banner',
    method: 'post',
    data: data
  })
}


export function uploadArticleFile(data) {
  return request({
    url: '/common/upload/article',
    method: 'post',
    data: data
  })
}

export function uploadPartnersLogoFile(data) {
  return request({
    url: '/common/upload/partnersLogo',
    method: 'post',
    data: data
  })
}


export function uploadFileByUrl(url,data) {
  return request({
    url: '/common/upload/'+url,
    method: 'post',
    data: data
  })
}


export function BMPGL(ak) {
  return new Promise(function(resolve, reject) {
    window.init = function() {
      // eslint-disable-next-line
      resolve(BMapGL)
    };
    const script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = `http://api.map.baidu.com/api?v=1.0&type=webgl&ak=${ak}&callback=init`;
    script.onerror = reject;
    document.head.appendChild(script)
  })
}



